﻿
using LocalService.Local.Interfaces;
using LocalService.Impl;
using OnTheWay.Domain;
namespace LocalService
{
    public class LocalFactory
    {
        ///// <summary>
        ///// WCF客户端
        ///// </summary>
        //static BlackMofoServiceClient Client = null;
        ///// <summary>
        ///// 获取WCF客户端
        ///// </summary>
        ///// <returns>WCF客户端</returns>
        //public static BlackMofoServiceClient GetBlackMofoServiceClient()
        //{
        //    if (Client == null)
        //    {
        //        try
        //        {
        //            Client = new BlackMofoServiceClient();
        //            if (Client.State != System.ServiceModel.CommunicationState.Opened)
        //            {
        //                //打开Web服务
        //                Client.Open();
        //            }
        //        }
        //        catch
        //        {
        //            if (Client != null && Client.State != System.ServiceModel.CommunicationState.Closed)
        //            {
        //                //关闭Web服务
        //                Client.Close();
        //            }
        //        }
        //    }
        //    return Client;
        //}


        #region 本地Exhibit对象接口

        static IExhibitLocal _ExhibitLocal = new ExhibitLocalImpl();
        /// <summary>
        /// 本地人员对象接口
        /// </summary>
        public static IExhibitLocal ExhibitLocal
        {
            get
            {
                if (_ExhibitLocal == null)
                {
                    _ExhibitLocal = new ExhibitLocalImpl();
                }
                return _ExhibitLocal;
            }
        }

        #endregion 本地Exhibit对象接口

        #region 本地ExhibitType对象接口

        static IExhibitTypeLocal _ExhibitTypeLocal = new ExhibitTypeLocalImpl();
        /// <summary>
        /// 本地人员对象接口
        /// </summary>
        public static IExhibitTypeLocal ExhibitTypeLocal
        {
            get
            {
                if (_ExhibitTypeLocal == null)
                {
                    _ExhibitTypeLocal = new ExhibitTypeLocalImpl();
                }
                return _ExhibitTypeLocal;
            }
        }

        #endregion 本地ExhibitType对象接口

        #region 本地ExhibitUnit对象接口

        static IExhibitUnitLocal _ExhibitUnitLocal = new ExhibitUnitLocalImpl();
        /// <summary>
        /// 本地人员对象接口
        /// </summary>
        public static IExhibitUnitLocal ExhibitUnitLocal
        {
            get
            {
                if (_ExhibitUnitLocal == null)
                {
                    _ExhibitUnitLocal = new ExhibitUnitLocalImpl();
                }
                return _ExhibitUnitLocal;
            }
        }

        #endregion 本地ExhibitUnit对象接口

        #region 本地SysAdmin对象接口

        static ISysAdminLocal _SysAdminLocal = new SysAdminLocalImpl();
        /// <summary>
        /// 本地人员对象接口
        /// </summary>
        public static ISysAdminLocal SysAdminLocal
        {
            get
            {
                if (_SysAdminLocal == null)
                {
                    _SysAdminLocal = new SysAdminLocalImpl();
                }
                return _SysAdminLocal;
            }
        }

        #endregion 本地SysAdmin对象接口

        #region 本地User对象接口

        static IUserLocal _UserLocal = new UserLocalImpl();
        /// <summary>
        /// 本地人员对象接口
        /// </summary>
        public static IUserLocal UserLocal
        {
            get
            {
                if (_UserLocal == null)
                {
                    _UserLocal = new UserLocalImpl();
                }
                return _UserLocal;
            }
        }

        #endregion 本地SysAdmin对象接口

        public static void SetWebServiceUrl(string url)
        {
            DataService<IBlackMofoService>.SetWebServiceUrl(url);
        }
    }
}
